/*
 * FindDialog.java
 *
 * Created on January 3, 2001, 10:33 PM
 */


/**
 *
 * @author  STURC
 * @version 
 */

package com.gemalto.Kryptik.Gui;

import com.gemalto.Kryptik.Gui.*;
import com.gemalto.Kryptik.Util.*;
import javax.swing.*;

public class FindDialog extends javax.swing.JDialog {

    /** Creates new form FindDialog */
    public FindDialog(SearchableTextAreaInterface parent,boolean modal) {
        super ();
        this.parent = parent;
        initComponents ();
        pack ();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the FormEditor.
     */
    private void initComponents() {//GEN-BEGIN:initComponents
	ImageIcon icon = Util.getIcon("find.gif");
        jLabel1 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jPanel1 = new javax.swing.JPanel();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                closeDialog(evt);
            }
        }
        );

        this.setUndecorated(true);
        this.getRootPane().setWindowDecorationStyle(JRootPane.QUESTION_DIALOG);
        
        this.setTitle("Text to find:");
        //jLabel1.setText("Text to find:");
        jLabel1.setIcon(icon);        
        getContentPane().add(jLabel1, java.awt.BorderLayout.WEST);
        
        
        jTextField1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField1ActionPerformed(evt);
            }
        }
        );
        
        getContentPane().add(jTextField1, java.awt.BorderLayout.CENTER);
        
        
        
        jButton2.setText("Find");
          jButton2.addActionListener(new java.awt.event.ActionListener() {
              public void actionPerformed(java.awt.event.ActionEvent evt) {
                  jButton2ActionPerformed(evt);
              }
          }
          );
          jPanel1.add(jButton2);
          
          
        jButton3.setText("Cancel");
          jButton3.addActionListener(new java.awt.event.ActionListener() {
              public void actionPerformed(java.awt.event.ActionEvent evt) {
                  jButton3ActionPerformed(evt);
              }
          }
          );
          jPanel1.add(jButton3);
          
          
        getContentPane().add(jPanel1, java.awt.BorderLayout.SOUTH);
        
    }//GEN-END:initComponents

  private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed
// Add your handling code here:
      jButton2ActionPerformed(evt);
  }//GEN-LAST:event_jTextField1ActionPerformed

  private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
// Add your handling code here:
        parent.find(jTextField1.getText());
        setVisible (false);
        dispose ();
  }//GEN-LAST:event_jButton2ActionPerformed

  private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
// Add your handling code here:
     setVisible (false);
     dispose ();
  }//GEN-LAST:event_jButton3ActionPerformed

    /** Closes the dialog */
    private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
        setVisible (false);
        dispose ();
    }//GEN-LAST:event_closeDialog

    
    public void setVisible(boolean b){
        super.setVisible(b);
        if (b) {
            jTextField1.requestFocus();
            jTextField1.selectAll();
        }
    }
    
private SearchableTextAreaInterface parent;
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel jLabel1;
private javax.swing.JTextField jTextField1;
private javax.swing.JPanel jPanel1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
// End of variables declaration//GEN-END:variables

}
